package com.juntu.loginlib.ui;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

/**
 * Created by cj on 2021/2/19.
 * Email:codesexy@163.com
 * Function:
 * desc:
 */
abstract class BaseActivity extends AppCompatActivity {


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        beforeInitView(savedInstanceState);
        initView(savedInstanceState);
        loadData();
    }


    protected void beforeInitView(Bundle savedInstanceState) {

    }

    protected void loadData() {

    }

    protected abstract int getLayoutId();

    /**
     * 保存登录信息
     *
     * @param loginResult
     */
    protected abstract void saveLoginInfo(String loginResult);


    /**
     * 初始化view
     */
    protected void initView(Bundle savedInstanceState) {

    }


    /**
     * 打开主界面
     */
    protected abstract void startMainActivity();

    /**
     * 各自解析相应的配置实体
     *
     * @param config
     */
    protected abstract void parseConfig(String config);


    protected void showDialog(String msg) {

    }

    protected void dismissDialog() {

    }


    protected void showErrorTips(String msg) {

    }
}
